package beans;

import entities.PagosDetalle;
import controllers.PagosDetalleFacade;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ManagedBean(name = "pagosDetalleController")
@ViewScoped
public class PagosDetalleController extends AbstractController<PagosDetalle> implements Serializable {

    @EJB
    private PagosDetalleFacade ejbFacade;

    public PagosDetalleController() {
        super(PagosDetalle.class);
    }

    @PostConstruct
    public void init() {
        super.setFacade(ejbFacade);
    }

    @Override
    protected void setEmbeddableKeys() {
        this.getSelected().getPagosDetallePK().setNroRecibo(this.getSelected().getPagosCabecera().getNroRecibo());
        this.getSelected().getPagosDetallePK().setCodCliente(this.getSelected().getClientes().getCodCliente());
        this.getSelected().getPagosDetallePK().setNroCuota(this.getSelected().getCuotasACobrar().getCuotasACobrarPK().getNroCuota());
        this.getSelected().getPagosDetallePK().setNroFactura(this.getSelected().getCuotasACobrar().getCuotasACobrarPK().getNroFactura());
    }

    @Override
    protected void initializeEmbeddableKey() {
        this.getSelected().setPagosDetallePK(new entities.PagosDetallePK());
    }
}
